package com.yuanhua.sim.business.controller;


import com.yuanhua.core.base.R;
import com.yuanhua.sim.business.dto.LoginDTO;
import com.yuanhua.sim.business.dto.LoginParamDTO;
import com.yuanhua.sim.business.service.impl.AuthManager;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 登录控制器
 */
@RestController
public class LoginController {

    @Autowired
    private AuthManager authManager;

    //用户登录，返回token，携带token到nettyserver中校验
    @PostMapping("/login")
    @ApiOperation(notes = "登录", value = "登录")
    public R<LoginDTO> login(@Validated @RequestBody LoginParamDTO loginParamDTO) {
        //验证码校验通过，执行具体的登录认证逻辑
        R<LoginDTO> r = authManager.login(loginParamDTO.getAccount(), loginParamDTO.getPassword());
        return  r;
    }
}
